package com.projectbox.service;

import java.util.List;
import java.util.Map;

import com.projectbox.model.Resource;
import com.projectbox.model.Folder;


public interface ResourceService {

	/**
	 * The resource with the given id
	 */
	Resource findResource(Long id);
	
	/**
	 * Add the resource to the system
	 *
	 * @param file The resource content
	 * @param name The name of the resource
	 * @param description The description of the resource
	 * @param uid The id of the resource owner
	 * @param pid The id of the project where the new resource belong
	 * @param fid The id of the folder where the new resource belong
	 */
	void addResource(byte[] file, String name, String description, Long uid, Long pid, Long fid);
	
	/**
	 * Remove the given resource from the system
	 */
	void removeResource(Resource resource);
	
	Map<String, String> renameResource(Long rid, String newName);
	
	/**
	 * Returns a list of resources that are belong to the project with given id
	 */
	List<Resource> findAllProjectResources(Long pid);
	
	/**
	 * Returns a list of resources that are belong to the project with given id and
	 * it's not in a folder
	 */
	List<Resource> findProjectResources(Long pid);
	
	/**
	 * Returns a list of resources that are belong to the project with given id and
	 * it's create by the given user with given id
	 *
	 * @param uid The user id
	 * @param pid The project id
	 */
	List<Resource> findProjectResourcesByUserId(Long uid, Long pid);
	
	/**
	 *
	 * @param name
	 * @param preId
	 * @param pid
	 */
	void createNewFolder(String name, Long preId, Long pid);
	
	/**
	 * Delete a folder record with the given id from DB  
	 *
	 * @param fid The folder id
	 */
	void deleteFolder(Long fid);
   
	/**
	 * Rename a folder name with give the given folder id and new folder name
	 *
	 * @param fid The folder id
   * @param newName The new folder name
	 */
	Map<String,String> renameFolder(Long fid, String newName);
   
  /**
	 * Find all reasource under specified folder
	 *
	 * @param fid The folder id
	 */
	List<Resource> findResourcesByFolder(Long fid);
  
  /**
	 * Find all sub folders under specified folder
	 *
	 * @param fid The folder id
	 */
	List<Folder> findSubfolders(Long fid);
   
	/**
	 * Find all sub folders under specified project
	 *
	 * @param pid The project id
	 */
	List<Folder> findSubfoldersByPid(Long pid);
	
  /**
	 * Find folder object with the given folder id
	 *
	 * @param fid The folder id
	 */
	Folder findFolder(Long fid);
	
  /**
	 * Find the folder which current folder belongs to
	 *
	 * @param fid The current folder id
	 */
	List<Folder> findPreFoldersById(Long fid);
   
	/**
	 * Find all resources which belong to the current user
	 *
	 * @param uid The current user id
	 */
	List<Resource> findResourcesByUserId(Long uid);
   
	/**
	 * Get all latest updated resources of current user
	 *
	 * @param uid The current user id
	 */
	List<Resource> getLatestResources(Long uid);
	
  /**
	 * Get initial folder name with the given current folder name and parent folder id
	 *
	 * @param name The current folder name
   * @param preId The parent folder id
	 */
	String getInitialFolderName(String name, Long preId);
	
}